function mctest(T,Npath,Ndt)
%function mctest(T,Npath,Ndt)
tic
myfun=@(s) 1+s-s;
paths=zeros(Npath,51);
dt=T/Ndt;
for ii=2:51
    curtime=0.01*(ii-2)+(1:100)*dt;
    cursigma=myfun(curtime);
    paths(:,ii)=paths(:,ii-1)+(randn(Npath,100)*cursigma')*sqrt(dt);    
end
% curtime=(1:100)*dt; cursigma=myfun(curtime);
% paths(:,2)=paths(:,1)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.01+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,3)=paths(:,2)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.02+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,4)=paths(:,3)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.03+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,5)=paths(:,4)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.04+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,6)=paths(:,5)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.05+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,7)=paths(:,6)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.06+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,8)=paths(:,7)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.07+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,9)=paths(:,8)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.08+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,10)=paths(:,9)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.09+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,11)=paths(:,10)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.10+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,12)=paths(:,11)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.11+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,13)=paths(:,12)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.12+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,14)=paths(:,13)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.13+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,15)=paths(:,14)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.14+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,16)=paths(:,15)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.15+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,17)=paths(:,16)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.16+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,18)=paths(:,17)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.17+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,19)=paths(:,18)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.18+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,20)=paths(:,19)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.19+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,21)=paths(:,20)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.20+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,22)=paths(:,21)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.21+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,23)=paths(:,22)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.22+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,24)=paths(:,23)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.23+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,25)=paths(:,24)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.24+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,26)=paths(:,25)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.25+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,27)=paths(:,26)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.26+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,28)=paths(:,27)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.27+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,29)=paths(:,28)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.28+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,30)=paths(:,29)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.29+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,31)=paths(:,30)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.30+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,32)=paths(:,31)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.31+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,33)=paths(:,32)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.32+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,34)=paths(:,33)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.33+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,35)=paths(:,34)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.34+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,36)=paths(:,35)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.35+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,37)=paths(:,36)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.36+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,38)=paths(:,37)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.37+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,39)=paths(:,38)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.38+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,40)=paths(:,39)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.39+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,41)=paths(:,40)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.40+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,42)=paths(:,41)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.41+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,43)=paths(:,42)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.42+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,44)=paths(:,43)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.43+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,45)=paths(:,44)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.44+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,46)=paths(:,45)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.45+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,47)=paths(:,46)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.46+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,48)=paths(:,47)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.47+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,49)=paths(:,48)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.48+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,50)=paths(:,49)+(randn(Npath,100)*cursigma')*sqrt(dt);
% 
% curtime=0.49+(1:100)*dt; cursigma=myfun(curtime);
% paths(:,51)=paths(:,50)+(randn(Npath,100)*cursigma')*sqrt(dt);


    mcvar=sum(paths.^2,1)/Npath;
    toc
    plot((0:50)*0.5/50,mcvar)

